package eu.gline.km;

import java.util.HashMap;

import eu.gline.km.clients.KmClient;

import android.app.Application;

public class Core extends Application {
	
	private HashMap<String, KmClient> activeConnexion;
	
	public void onCreate() {
		super.onCreate();
		initializeVariables();
    }
	
	public void onLowMemory() {
		super.onLowMemory();
	}
	
	public boolean connectTo(String hashName, String hostname, int port, String password) {
		KmClient kmc = new KmClient(this, hashName);
		kmc.createClient(hostname, port, password);
		if (kmc.isConnected()) {
			activeConnexion.put(hashName, kmc);
			return true;
		} else {
			return false;
		}
	}
	
	private void initializeVariables() {	
		activeConnexion = new HashMap<String, KmClient>();	
	}

	public void removeClient(String kmClient) {
		activeConnexion.remove(kmClient);
	}
	
	public KmClient getClient(String hashName) {
		return activeConnexion.get(hashName);
	}

}
